define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {
    var Controller = {
        index: function () {
            Table.api.init({
                extend: {
                    index_url: 'yexam/question_error/index' + location.search,
                    edit_url: 'yexam/question_error/edit',
                    del_url: 'yexam/question_error/del',
                    //table: 'question_type',
                },
                pageList : [10,20,40,60,80]
            });
            let table = $('#table');
            // 初始化表格
            table.bootstrapTable({
                url : $.fn.bootstrapTable.defaults.extend.index_url,
                pk : 'id',
                columns: [
                    [
                        {checkbox : true},
                        {field: 'subject',title: '科目',operate : false},
                        {field: 'time',title: __('时间'),formatter: Table.api.formatter.datetime,operate: "RANGE",addClass: "datatimerange"},
                        {field: 'question_id',title: '试题ID'},
                        {field: 'feedback_person',title: '反馈人'},
                        {field: 'content',title: '反馈内容'},
                        {field: 'mark',title: '状态',searchList: {0 : '未处理',1 : '已处理'},formatter: Table.api.formatter.status,},
                        {field: "answer" ,title : "选项" ,},
                        {field: "type" ,title : "反馈类型" ,},
                        {field: 'operate', width: '130px', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,}
                    ]
                ],
                onClickRow: function (row,$elem) {
                    if (row.hasOwnProperty('id') && row.mark == 0)
                    {
                        $.post('yexam/question_error/setMark',{id : row.id},function (response) {
                            window.Fast.api.toastr(response.msg);
                        });
                    }
                }
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            formatter:{
            },
            bindevent: function () {
                $("#c-package_ids").data("params", function (obj) {
                    return {custom: {category_id: $("#c-category_id").val()}};
                });
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
